from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, FileField, BooleanField, SelectField, validators, DateTimeField
from datetime import datetime


class BlogForms(FlaskForm):
    title = StringField('主题')
    categoryid = SelectField('主题分类')
    author = StringField('作者')
    preface = StringField('序言')
    faceimage = FileField('图片')
    body = TextAreaField('详细内容')
    isshow = BooleanField('是否展示', default=1)
    releasetime = DateTimeField('时间', default=datetime.now())


class MessageForms(FlaskForm):
    name = StringField('姓名')
    email = StringField('邮箱')
    body = TextAreaField('信息')


class CommentForms(FlaskForm):
    name = StringField('姓名', default='游客')
    ip = StringField('ip地址')
    body = TextAreaField('内容', [validators.DataRequired('内容不能为空'), validators.length(max=111, message='字符长度不能超过111个~')])
    article_id = StringField()
    releasetime = DateTimeField()
